package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.RecSelItemEntity;
import com.jinmdz.fmis.mapper.mapper.provider.RecSelItemProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 接运已选随车物品明细关联表Mapper
 *
 * @author generator
 * @date 2020-07-06 11:20
 */
public interface RecSelItemMapper {

    /**
     * 增加RecSelItem
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-07-06 11:20
     */
    @InsertProvider(type = RecSelItemProvider.class, method = "insertRecSelItem")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertRecSelItem(@Param("entity") RecSelItemEntity entity);

    /**
     * 删除RecSelItem
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-07-06 11:20
     */
    @Update(" update rec_sel_item set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForRecSelItem(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改RecSelItem
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-07-06 11:20
     */
    @UpdateProvider(type = RecSelItemProvider.class, method = "updateRecSelItem")
    void updateRecSelItem(@Param("entity") RecSelItemEntity entity);

    /**
     * 查询RecSelItem实体
     *
     * @param id 主键
     * @return RecSelItemEntity
     * @author generator
     * @date 2020-07-06 11:20
     */
    @Select(" select id,deleted,rec_id,service_item_id,item_price,item_number,item_unit,item_charge,discount_charge,benefit_charge,reality_charge,charge_time,as_unsettled,as_settled,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version,item_name from rec_sel_item where id = #{id} and deleted = 0 limit 1 ")
    RecSelItemEntity getRecSelItemById(@Param("id") Integer id);

    /**
     * 查询RecSelItem列表
     *
     * @param entity 数据实体
     * @return RecSelItemEntity
     * @author generator
     * @date 2020-07-06 11:20
     */
    @SelectProvider(type = RecSelItemProvider.class, method = "listRecSelItem")
    ArrayList<RecSelItemEntity> listRecSelItem(@Param("entity") RecSelItemEntity entity);
}